package org.csu.mybigpro.controller;

import jakarta.annotation.Resource;
import org.csu.mybigpro.service.StudyAnalysisService;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

@RestController
@RequestMapping("/api/study_analysis")
public class StudyAnalysisController {

    @Resource
    private StudyAnalysisService studyAnalysisService;

    /**
     * 学习行为分析接口
     * 统计学生平均学习时长、访问频率、参与率等
     * @param studentId 学生ID
     * @return 统计结果Map
     */
    @GetMapping("/behavior")
    public Map<String, Object> analyzeStudyBehavior(@RequestParam Long studentId) {
        return studyAnalysisService.analyzeStudyBehavior(studentId);
    }

    /**
     * 学习效果评估接口
     * 结合作业、考试成绩评估学生学习效果
     * @param studentId 学生ID
     * @param courseId 课程ID
     * @return 评估结果Map
     */
    @GetMapping("/effect")
    public Map<String, Object> evaluateStudyEffect(@RequestParam Long studentId,
                                                   @RequestParam Long courseId) {
        return studyAnalysisService.evaluateStudyEffect(studentId, courseId);
    }

    /**
     * 个性化推荐接口
     * 根据学生表现生成个性化学习建议与辅导方案
     * @param studentId 学生ID
     * @param courseId 课程ID
     * @return 个性化推荐字符串
     */
    @GetMapping("/recommendation")
    public String generatePersonalizedRecommendation(@RequestParam Long studentId,
                                                     @RequestParam Long courseId) {
        return studyAnalysisService.generatePersonalizedRecommendation(studentId, courseId);
    }
}
